/// Drop trait类似于其他语言中的析构函数，当值离开作用域的时候执行此函数的代码
// 例子
#[derive(Debug)]
struct Dog {
    name: String,
    count: i32,
}
impl Drop for Dog {
    fn drop(&mut self) {
        println!("{} leave", self.name);
        self.count -= 1;
        println!("self.count = {}", self.count);

    }
}
fn main() {
    let a = Dog{
        name: String::from("WC"),
        count: 1, };

    {
        let b = Dog{
            name: String::from("DH"),
            count: 4, };
        println!("b = {:?}", &b);
    }

    println!("a = {:?}", &a);
}
